package com.fyyg.admin.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;

import com.fyyg.interfaces.TSysUserService;
import com.fyyg.model.TSysUser;




/**
 * @description：基础 controller
 * @date：2016/3/15 10:09
 */
public class BaseController {
	
	@Resource
	private TSysUserService userService;
	
	
	public Map<String, String> setBase(){
		Map<String, String> map = new HashMap<String, String>();
		map.put("OOS_PC_PATH", "http://www.fy135.com/");//"http://www.fy135.com/"
		return map;
	}
	
	/**
     * 获取当前登录用户对象
     * @return
     */
    public TSysUser getCurrentUser(String UID,HttpServletRequest request) {
    	TSysUser user = new TSysUser();
    	try {
    		if(!StringUtils.isBlank(UID)) {
    			user = userService.selectByPrimaryKey(Integer.parseInt(UID));
    			if(user!=null) {
    				request.getSession().setAttribute("UID", user.getUserId());
    			}
    		}
		} catch (Exception e) {
			e.printStackTrace();
		}
        return user;
    }
}
